package com.ysyx.ysyx_admin.config;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ysyx.ysyx_admin.mapper.AreaPojoMapper;
import com.ysyx.ysyx_admin.pojo.AreaPojo;
import org.redisson.api.RMap;
import org.redisson.api.RedissonClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * Created by IntelliJ IDEA.
 *
 * @description: xxxx接口/类
 * @author:郭宇轩
 * @create:2023/4/10 19:46
 */
//@Component
public class InitRedissonConfig implements ApplicationRunner {


    @Autowired
    private AreaPojoMapper areaPojoMapper;

    @Autowired
    private RedissonClient redissonClient;

    @Override
    public void run(ApplicationArguments args) throws Exception {
//        System.out.println("执行Redisson初始化");
//        QueryWrapper<AreaPojo> qw = new QueryWrapper<>();
//        List<AreaPojo> list = areaPojoMapper.selectList(qw);
//        for (AreaPojo a:list) {
////            System.out.println("area:"+ a.getAreaName());
////            redissonClient.getMap("Area:"+ a.getAreaName());
//            RMap<Object, Object> map = redissonClient.getMap("area:" + a.getAreaName());
//            map.put("area_id",a.getAreaId());
//            //左上
//            map.put("leftupLongitude",a.getLeftupLongitude());
//            map.put("leftupLatitude",a.getLeftupLatitude());
//            //右上
//            map.put("rightupLongitude",a.getRightupLongitude());
//            map.put("rightupLatitude",a.getRightupLatitude());
//
//            //左下
//            map.put("leftdownLongitude",a.getLeftdownLongitude());
//            map.put("leftdownLatitude",a.getLeftdownLatitude());
//
//            //右下
//            map.put("rightdownLongitude",a.getRightdownLongitude());
//            map.put("rightdownLatitude",a.getRightdownLatitude());
//        }
    }
}
